package com.zmn.oms.dubbo.impl.zmn.serviceprovider.statement;

import org.apache.dubbo.config.annotation.Service;
import com.google.common.collect.Lists;
import com.zmn.common.constant.GlobalConsts;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.common.utils.reflect.BeanMapper;
import com.zmn.oms.dubbo.dto.zmn.order.OrderListPageDRO;
import com.zmn.oms.dubbo.dto.zmn.order.serviceprovider.OrderStatementDIO;
import com.zmn.oms.dubbo.impl.zmn.order.OrderWorkBaseRemoteService;
import com.zmn.oms.dubbo.interfaces.zmn.serviceprovider.statement.OrderStatementListRemoteService;
import com.zmn.oms.dubbo.utils.DubboConsts;
import com.zmn.oms.model.entity.work.OrderWorkQuery;
import com.zmn.oms.zmn.business.interfaces.work.ZsOrderWorkQueryBService;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @author ：SongWeidong
 * @date ：2020/8/17 15:43
 * @description：结算明细
 */
@Service(loadbalance = "roundrobin", timeout = 5000, retries = 2, version = DubboConsts.INTERFACE_VERSION, validation = "false")
public class OrderStatementListRemoteServiceImpl extends OrderWorkBaseRemoteService implements OrderStatementListRemoteService {

    private static final String TAG = "服务商-结算明细";

    @Resource
    protected ZsOrderWorkQueryBService zsOrderWorkQueryBService;

    @Override
    public ResponseDTO<OrderListPageDRO> listOrder(OrderStatementDIO queryDIO) {

        logger.info("[{}] 服务商结算订单列表：{}", TAG, queryDIO);
        Objects.requireNonNull(queryDIO.getManageCompanyId());

        OrderWorkQuery query = BeanMapper.map(queryDIO, OrderWorkQuery.class);
        query.setManageCompanyIdList(Lists.newArrayList(queryDIO.getManageCompanyId()));

        query.setDefaultOrder(GlobalConsts.YES);
        query.setOrderField("receiveTime");
        // 处理查询条件
        query.setSpStatement(GlobalConsts.YES);
        return super.listOrder(query);
    }
}
